package com.zykj.iterator;

import java.util.Iterator;

/**
 * @author zhoulj(周利军) [1217102780@qq.com]
 * @Title: WucanIterator
 * @Project: ${MODEL_NAME}
 * @Module ID:   <(模块)类编号，可以引用系统设计中的类编号>
 * @Comments: <对此类的描述，可以引用系统设计中的描述>
 * @JDK version used:      <JDK1.8> 29
 * @since 2019/1/7-21:29
 */
public class WucanIterator implements Iterator {
    MenuItem[] menuItems;
    int position = 0 ;
    public WucanIterator(MenuItem[] menuItems) {
        this.menuItems = menuItems;

    }

    @Override
    public boolean hasNext() {
        if (position >= menuItems.length || menuItems[position] == null) {
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        MenuItem menuItem = menuItems[position];
        position = position+1;
        return menuItem;
    }
}
